package com.bwie.controller;

import com.bwie.pojo.Attr;
import com.bwie.service.AttrService;
import com.bwie.service.IUserService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author GaoYiJie
 * @Description
 * @Create 2025/2/27 9:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/shop/attr")
public class AttrController {

    @Autowired
    AttrService attrService;

    @Autowired
    IUserService iUserService;

    /**
     * 属性列表
     * @return
     */
    @PostMapping("/getAttrList")
    public R getAttrList(){
        return attrService.getAttrList();
    }

    /**
     * 新增属性
     * @return
     */
    @PostMapping("/addAttr")
    public R addAttr(@RequestBody Attr attr){
        return attrService.addAttr(attr);
    }

    /**
     * 修改属性
     * @return
     */
    @PostMapping("/updateAttr")
    public R updateAttr(@RequestBody Attr attr){
        return attrService.updateAttr(attr);
    }

    /**
     * 删除属性
     * @return
     */
    @PostMapping("/deleteAttr/{attrId}")
    public R deleteAttr(@PathVariable("attrId") Integer attrId){
        return attrService.deleteAttr(attrId);
    }

    /**
     * 根据ID获取用户(openFeign)
     * @param userId
     * @return
     */
    @PostMapping("/getUserById/{userId}")
    public R getUserById(@PathVariable("userId") Integer userId){
        return iUserService.getUserById(userId);
    }


}
